package com.isoftstone.service.Impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.isoftstone.dao.RefundDao;
import com.isoftstone.entity.CK_Prescription;
import com.isoftstone.entity.C_Medicine;
import com.isoftstone.entity.C_Prescription;
import com.isoftstone.entity.Patient;
import com.isoftstone.entity.W_Medicine;
import com.isoftstone.entity.W_Prescription;
import com.isoftstone.service.RefundService;

@Service("RefundService")
public class RefundServiceImpl implements RefundService{

	@Autowired
	private RefundDao RefundDao;
	
	@Override
	public List<Patient> getPatient(String patient_name,String patient_idcard) {
		// TODO Auto-generated method stub
		List<Patient> patient = RefundDao.getPatient(patient_name, patient_idcard);
		System.out.println("11111111111'"+patient);
		return patient;
	}

	@Override
	public List<C_Prescription> getCmPrescription(String guahao_id) {
		// TODO Auto-generated method stub
		List<C_Prescription> cmlist = RefundDao.getCmPrescription(guahao_id);
		System.out.println("22222222222222'"+cmlist);
		return cmlist;
	}

	@Override
	public List<W_Prescription> getWmPrescription(String guahao_id) {
		// TODO Auto-generated method stub
		List<W_Prescription> wmlist = RefundDao.getWmPrescription(guahao_id);
		System.out.println("3333333333333333333'"+wmlist);
		return wmlist;
	}

	@Override
	public List<CK_Prescription> getCkPrescription(String guahao_id) {
		// TODO Auto-generated method stub
		List<CK_Prescription> cklist = RefundDao.getCkPrescription(guahao_id);
		System.out.println("44444444444444'"+cklist);
		return cklist;
	}

	@Override
	public boolean insertFee(String cost_id, Double ls_price,Date ls_data) {
		// TODO Auto-generated method stub
		if(cost_id!=null && ls_price!=null &&ls_data!=null){
			boolean flag =RefundDao.insertFee(cost_id, ls_price, ls_data);
			if(flag){
				return true;
			}
		}
		return false;
	}

	@Override
	public boolean ckRefund(Double ck_amount_refund,String ck_id, String guahao_id) {
		// TODO Auto-generated method stub
		if(ck_amount_refund!=null && guahao_id!=null){
			ck_amount_refund = RefundDao.ckRefund1(ck_id, guahao_id)+ck_amount_refund;
			boolean flag =RefundDao.ckRefund(ck_amount_refund,ck_id, guahao_id);
			if(flag){
				return true;
			}
		}
		return false;
	}

	@Override
	public boolean cmRefund(Double cm_amount_refund,String cm_id, String guahao_id) {
		// TODO Auto-generated method stub
		if(cm_amount_refund!=null && guahao_id!=null){
			cm_amount_refund = RefundDao.cmRefund1(cm_id, guahao_id)+cm_amount_refund;
			boolean flag =RefundDao.cmRefund(cm_amount_refund,cm_id, guahao_id);
			if(flag){
				return true;
			}
		}
		return false;
	}

	@Override
	public boolean wmRefund(Double wm_amount_refund,String wm_id, String guahao_id) {
		// TODO Auto-generated method stub
		if(wm_amount_refund!=null && guahao_id!=null){
			wm_amount_refund = RefundDao.wmRefund1(wm_id, guahao_id)+wm_amount_refund;
			boolean flag =RefundDao.wmRefund(wm_amount_refund,wm_id, guahao_id);
			if(flag){
				return true;
			}
		}
		return false;
	}



}
